import time
import json


def formatTime(t):
    ''' 输出 格式 为 2022-01-01 00:00:00 '''
    t = time.localtime(t)
    return time.strftime('%Y-%m-%d %H:%M:%S', t)

def formatDate(t):
    ''' 输出 格式 为 2022-01-01 '''
    t = time.localtime(t)
    return time.strftime('%Y-%m-%d', t)

def _tryParseJson(data):
    '''尝试解析json数据'''
    if not data:
        return None
    try:
        data = json.loads(data)
        return data
    except json.JSONDecodeError as e:
        return None
    except Exception as e:
        print('未知错误:', e)
        return None

if __name__ == '__main__':
    # 简单的测试
    print(formatTime(time.time()))
    print(formatTime(time.time() - 35 * 60))
    print(formatDate(time.time()))
    print(formatDate(time.time() - 35 * 60))